var server="http://t.pasp.cn/newsapp/webservices/";

//url获取参数
$.extend({  
  getUrlVars: function(){  
    var vars = [], hash;  
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');  
    for(var i = 0; i < hashes.length; i++){  
      hash = hashes[i].split('=');  
      vars.push(hash[0]);  
      vars[hash[0]] = hash[1];  
    }  
    return vars;  
  }, 
  getUrlVar: function(name){  
    return $.getUrlVars()[name];  
  }  
}); 
/*
获取相应的值的方法:
// Get object of URL parameters  
var allVars = $.getUrlVars();  
// Getting URL var by its nam  
var byName = $.getUrlVar('name');
*/

//web服务的jsonp通信
var WebService = function() {
	//地址。
	var url = "";
	this.setURL = function(_url) {
		url = _url;
	}
	//方法名称。
	var opName = "";
	this.setOpName = function(_opName) {
		opName = _opName;
	}
	/**
		*参数
		*hash数组
		*/
	var paras = "";
	this.setParas = function(parasArray) {
		var isFirst = true;
		for (key in parasArray) {
			if (isFirst) {
				paras += "?" + key + "=" + parasArray[key];
				isFirst = false;
			} else paras += "&" + key + "=" + parasArray[key];
		}
	}

	this.clearParas = function() {
		paras = "";
	};

	//成功后数据返回处理函数。
	//带有个参数，参数为返回后的数据。
	//function (result) {  //返回json类型数据   
	//						alert(result.loginmsg);
	//		   }
	var callBack = null;
	this.setCallBack = function(_callBack) {
		callBack = _callBack;
	}

	var errorCallBack = null;
	this.setErrorCallBack = function(_errorCallBack) {
		errorCallBack = _errorCallBack;
	}

	this.LoadData = function() {
		var webUrl = url + opName + paras;
		$.ajax({
			type: "GET",
			url: webUrl,
			//所请求的webservice服务url地址								 
			dataType: "jsonp",
			jsonp: 'callback',
			success: callBack,
			Error: errorCallBack
		});
	}
}
